<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/StakeholderTemplate.xhtml">
    <ui:define name="begin">
        <f:view beforePhase="#{mealManagerBean.initMealList}"/>
    </ui:define>
    <ui:define name="contentInsert">  
        <h:body>
            <h:form id="formMain">
                <p:panel id="panel" header="Add New Set Meal">
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />
                    
                    <h:panelGrid  >                   
                        <h:outputLabel for="setMealName" style="font-weight: bold" value="Set Meal Name: " />
                        <h:inputText id="setMealName" required="true" label="Set Meal Name" requiredMessage="Set meal name is required." value="#{mealManagerBean.selectedSetMeal.name}">
                        </h:inputText>
                        <p:message for="setMealName" />


                        <h:outputLabel for="originalPrice" style="font-weight: bold" value="Original Price: " />
                        <h:inputText id="originalPrice" required="true" label="Original Price" requiredMessage="Original price is required." value="#{mealManagerBean.selectedSetMeal.originalPrice}">
                        </h:inputText>
                        <p:message for="originalPrice" />

                        <h:outputLabel for="description" style="font-weight: bold" value="Description: " />
                        <h:inputText id="description" required="true" label="Description" requiredMessage="Description is required." value="#{mealManagerBean.selectedSetMeal.description}">
                        </h:inputText>
                        <p:message for="description" />

                        <h:outputText value="Visible to Customers, check for YES: "/>
                        <h:selectBooleanCheckbox id="checkbox" value="#{mealManagerBean.selectedSetMeal.visibility}"
                                                 title="click it to select or deselect"/>

                        <p:fileUpload id="upload" fileUploadListener="#{mealManagerBean.handleImageUploadSetMeal}" 
                                      allowTypes="*.jpg;*.png;*.gif;" description="Images" update ="msg gi"/>     
                        <p:growl id="msg" />

                        <h:outputLabel for="blank" style="font-weight: bold" value=""/>

                        <p:dataTable var="mealList" value="#{mealManagerBean.mealList}" selection="#{mealManagerBean.selectedMeals}" paginator="true" rows="10">
                            <p:column selectionMode="multiple" />

                            <p:column sortBy="#{mealList.name}" filterBy="#{mealList.name}">  
                                <f:facet name="header">  
                                    <h:outputText value="Meal Name" />  
                                </f:facet>  
                                <h:outputText value="#{mealList.name}" />  
                            </p:column>  

                            <p:column sortBy="#{mealList.description}" filterBy="#{mealList.description}">  
                                <f:facet name="header">  
                                    <h:outputText value="Description" />  
                                </f:facet>  
                                <h:outputText value="#{mealList.description}" />  
                            </p:column>  

                            <p:column sortBy="#{mealList.type.name}" filterBy="#{mealList.type.name}">  
                                <f:facet name="header">  
                                    <h:outputText value="Type" />  
                                </f:facet>  
                                <h:outputText value="#{mealList.type.name}" />  
                            </p:column> 
                        </p:dataTable>

                    </h:panelGrid>

                    <p:commandButton id="btn" value="Save Set Meal" update="panel" actionListener="#{mealManagerBean.saveSetMeal}" ajax="true" />
                </p:panel>
            </h:form>
        </h:body>
    </ui:define>
</ui:composition>
